home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11849 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.8 KB  |  61 lines

  1. Path: solon.com!not-for-mail
  2. From: rich@kastle.com (Richard Krehbiel)
  3. Newsgroups: comp.lang.c.moderated,comp.lang.c
  4. Subject: Re: ada-like naming scheme?
  5. Date: 26 Mar 1996 18:55:41 -0600
  6. Organization: Kastle Development Associates
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4ja3md$p5e@solutions.solon.com>
  10. References: <4j41gd$nij@solutions.solon.com>
  11. Reply-To: rich@kastle.com
  12. NNTP-Posting-Host: solutions.solon.com
  13. X-Newsreader: Forte Free Agent 1.0.82
  14.  
  15. lloyd@upsilon.cs.fsu.edu (Justin C Lloyd) wrote:
  16.  
  17. >Does anyone know how to do write a .c file so that you have to include the
  18. >name of c file in any function calls, similar to ada?
  19.  
  20. There's no automatic way to do this.  You will have to do it by
  21. adopting some convention.
  22.  
  23. >In ada, for instance:
  24.  
  25. >   ada.text_io.get(x);
  26.  
  27. >means there is a collection of procedures named ada (a package), and in that
  28. >one named text_io, and in the text_io collection, one called get.
  29.  
  30. >Maybe a way to do this by putting everything in a struct? For instance...
  31.  
  32. >   float_sort.quicksort(float_array);
  33. >   integer_sort.quicksort(int_array);
  34. >   integer_sort.selection_sort(int_array);
  35.  
  36. You could do just that...
  37.  
  38. typedef int (*int_sort_fp)(int *), int_sort_f();
  39. typedef int (*float_sort_fp)(float *), float_sort_f();
  40.  
  41. extern int_sort_f int_sort_quicksort;
  42. extern float_sort_f float_sort_quicksort;
  43.  
  44. struct
  45. {
  46.     int_sort_fp quicksort;
  47. } int_sort = { int_sort_quicksort };
  48.  
  49. struct
  50. {
  51.     float_sort_fp quicksort;
  52. } float_sort = { float_sort_quicksort };
  53.  
  54. >From curiosity, why not just adopt a naming convention that prepends
  55. the package/module names to the function name?  Why not simply call
  56. them int_sort_quicksort() and float_sort_quicksort()?
  57.  
  58. --
  59. Richard Krehbiel, Kastle Systems, Arlington VA USA
  60. rich@kastle.com (work) or richk@mnsinc.com (personal)
  61.